package tech.veedo.ragdoll;

import org.springframework.boot.context.properties.ConfigurationProperties;
import tech.veedo.ragdoll.config.PrintMode;

@ConfigurationProperties(prefix = "veedo.ragdoll")
class RagdollProperties {

    private GlobalAdvice globalAdvice;

    private ExceptionAdvice exceptionAdvice;

    /**
     * 全局返回 配置项
     */
    protected static class GlobalAdvice {

        /**
         * 是否启用
         */
        private Boolean enabled = false;

        /**
         * 返回统一拦截的包路径，如果没有，则全局返回
         */
        private String basePackages;

        /**
         * 不需要使用全局返回结果的方法
         */
        private String ignoreMethods;

        public Boolean getEnabled() {
            return enabled;
        }

        public void setEnabled(Boolean enabled) {
            this.enabled = enabled;
        }

        public String getBasePackages() {
            return basePackages;
        }

        public void setBasePackages(String basePackages) {
            this.basePackages = basePackages;
        }

        public String getIgnoreMethods() {
            return ignoreMethods;
        }

        public void setIgnoreMethods(String ignoreMethods) {
            this.ignoreMethods = ignoreMethods;
        }
    }

    /**
     * 错误全全局返回配置项
     */
    protected static class ExceptionAdvice {

        /**
         * 是否启用
         */
        private Boolean enabled = false;

        /**
         * 返回错误时，是否显示真正的错误信息
         */
        private Boolean showRealErrorMessage = true;

        /**
         * 错误打印显示模式,默认Log
         */
        private PrintMode mode = PrintMode.LOG;

        public Boolean getEnabled() {
            return enabled;
        }

        public void setEnabled(Boolean enabled) {
            this.enabled = enabled;
        }

        public Boolean getShowRealErrorMessage() {
            return showRealErrorMessage;
        }

        public void setShowRealErrorMessage(Boolean showRealErrorMessage) {
            this.showRealErrorMessage = showRealErrorMessage;
        }

        public PrintMode getMode() {
            return mode;
        }

        public void setMode(PrintMode mode) {
            this.mode = mode;
        }

    }

    public GlobalAdvice getGlobalAdvice() {
        return globalAdvice;
    }

    public void setGlobalAdvice(GlobalAdvice globalAdvice) {
        this.globalAdvice = globalAdvice;
    }

    public ExceptionAdvice getExceptionAdvice() {
        return exceptionAdvice;
    }

    public void setExceptionAdvice(ExceptionAdvice exceptionAdvice) {
        this.exceptionAdvice = exceptionAdvice;
    }
}
